Get all modifications to apply with only one rest call to the network-modification-server#31
Conversation
…-modification-server Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
📝 WalkthroughWalkthroughReplaced multiple per-UUID REST calls with a single batched GET to Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(200,200,255,0.5)
participant Caller
end
rect rgba(200,255,200,0.5)
participant NetworkModificationRestService as Service
end
rect rgba(255,200,200,0.5)
participant RemoteAPI as Remote Server
end
Caller->>Service: getModifications(List<UUID> uuids)
Service->>RemoteAPI: GET /v1/network-composite-modifications/network-modifications?uuids=...&onlyMetadata=false
RemoteAPI-->>Service: 200 OK (ModificationInfos[])
Service-->>Caller: List<ModificationInfos> (converted or empty)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@monitor-worker-server/src/main/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestService.java`:
- Around line 39-42: The queryParam call using modificationsUuids may be bound
to the varargs overload and not expand the list into repeated uuids=...
parameters; update the UriComponentsBuilder usage (the UriComponentsBuilder call
that builds the path with NETWORK_MODIFICATION_SERVER_API_VERSION and the
queryParam("uuids", modificationsUuids) invocation) to explicitly expand the
collection—either by passing the list elements (e.g., spread/iterate) or casting
to a Collection (e.g., (Collection<?>) modificationsUuids) so that queryParam
produces repeated uuids entries; ensure the onlyMetadata queryParam remains
unchanged.
🧹 Nitpick comments (2)
monitor-worker-server/src/main/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestService.java (1)
38-46: Avoid remote call for empty UUID lists.If
modificationsUuidsis empty or null, this builds a URL like...?uuids=and still calls the server. Consider short‑circuiting to avoid unintended server behavior and wasted I/O.♻️ Suggested guard
public List<ModificationInfos> getModifications(List<UUID> modificationsUuids) { + if (modificationsUuids == null || modificationsUuids.isEmpty()) { + return List.of(); + } String path = this.networkModificationServerBaseUri + UriComponentsBuilder.fromPath(DELIMITER + NETWORK_MODIFICATION_SERVER_API_VERSION + DELIMITER + "network-composite-modifications" + DELIMITER + "network-modifications") .queryParam("uuids", modificationsUuids)monitor-worker-server/src/test/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestServiceTest.java (1)
63-81: UsequeryParam()matcher for order‑independent query parameter assertions.Lines 65 and 80 assert the full URL string; query parameter ordering changes will break the test even if behavior is correct. Use
MockRestRequestMatchers.queryParam()instead for robust, order‑independent matching.✅ More robust matcher
- .andExpect(MockRestRequestMatchers.requestTo("http://network-modification-server/v1/network-composite-modifications/network-modifications?uuids=" + MODIFICATION_1_UUID + "&uuids=" + MODIFICATION_2_UUID + "&onlyMetadata=false")) + .andExpect(MockRestRequestMatchers.requestTo("http://network-modification-server/v1/network-composite-modifications/network-modifications")) + .andExpect(MockRestRequestMatchers.queryParam("uuids", MODIFICATION_1_UUID.toString(), MODIFICATION_2_UUID.toString())) + .andExpect(MockRestRequestMatchers.queryParam("onlyMetadata", "false"))- server.expect(MockRestRequestMatchers.method(HttpMethod.GET)) - .andExpect(MockRestRequestMatchers.requestTo("http://network-modification-server/v1/network-composite-modifications/network-modifications?uuids=" + MODIFICATION_ERROR_UUID + "&onlyMetadata=false")) + server.expect(MockRestRequestMatchers.method(HttpMethod.GET)) + .andExpect(MockRestRequestMatchers.requestTo("http://network-modification-server/v1/network-composite-modifications/network-modifications")) + .andExpect(MockRestRequestMatchers.queryParam("uuids", MODIFICATION_ERROR_UUID.toString())) + .andExpect(MockRestRequestMatchers.queryParam("onlyMetadata", "false"))
...c/main/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@monitor-worker-server/src/main/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestService.java`:
- Around line 38-46: In getModifications in NetworkModificationRestService,
guard against a null or empty modificationsUuids before building the URI: if
modificationsUuids is null or modificationsUuids.isEmpty(), immediately return
List.of() to avoid NPE from modificationsUuids.toArray() and skip the network
call; otherwise proceed to build the path (using
networkModificationServerBaseUri and UriComponentsBuilder) and call
networkModificationServerRest.getForObject as before. Ensure the short-circuit
uses the same return type (List<ModificationInfos>) and keeps the existing
behavior for non-empty input.
...c/main/java/org/gridsuite/monitor/worker/server/services/NetworkModificationRestService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
thangqp
left a comment
There was a problem hiding this comment.
Tests pass for the normal case.
However, if the composite modification is deleted, the worker run does not stop. This behavior needs to be revisited.
|



PR Summary
Get all modifications to apply with only one rest call to the network-modification-server
should be merged together with : gridsuite/network-modification-server#757